package leetcode.code0853;

import java.util.Arrays;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;

public class Solution implements IDebug {

	public int carFleet(int target, int[] position, int[] speed) {
		int len = position.length;
		int[][] infos = new int[len][2];
		for (int i = 0; i < len; i++) {
			infos[i][0] = position[i];
			infos[i][1] = speed[i];
		}
		Arrays.sort(infos, (a, b) -> b[0] - a[0]);
		double arrival = Integer.MIN_VALUE;
		int ans = 0;
		for (int i = 0; i < len; i++) {
			int[] info = infos[i];
			double cur = (double)(target - info[0]) / info[1];
			System.out.println(cur);
			if (cur > arrival) {
				ans += 1;
				arrival = cur;
			}
		}
		return ans;
	}

	@Override
	public void debug1() {
		HelpDebug.compare(3, this.carFleet(12, HelpDebug.str2array3("[10,8,0,5,3]"), HelpDebug.str2array3("[2,4,1,1,3]")));

	}

	@Override
	public void debug2() {
		HelpDebug.compare(6, this.carFleet(10, HelpDebug.str2array3("[8,3,7,4,6,5]"), HelpDebug.str2array3("[4,4,4,4,4,4]")));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
